package ar.com.indra.controller;

import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;

public class ValidatePassword  implements Validator{

	public void validate(FacesContext context, UIComponent arg1, Object arg2)
			throws ValidatorException {
		
		System.out.println("*****************ValidatePassword************** ----");
		System.out.println("password : " + arg2.toString());
		
        String pass = (String) arg2;
        
        if(!pass.equals("pepe")) {
            FacesMessage message = new FacesMessage();
            message.setSeverity(FacesMessage.SEVERITY_ERROR);
            message.setSummary("Acceso denegado");
            context.addMessage("userForm:password", message);
            throw new ValidatorException(message);
        }
		
	}

}
